import state from "./state"

export default {
  isLoading(state){
    // console.log(state)
    state.loading=true
  },
  notLoading(state){
    // console.log(state)
    state.loading=false
  },
  setInputValue(state,value){
    state.searchValue=value
  },
  setSearchList(state,value){
    state.searchList=value
  },
  // setIsUpdate(state){
  //   state.isUpdate=true
  // },
 showList(state,flag){
    state.showList=flag
  },
  setSongsObject(state,val){
    if(!val){
      state.songsObject={}  
    }else{
      state.songsObject=val
    }
  },
  showPlayBox(state,val){
    state.showPlayBox=val
  },
  getSwiperPic(state,val){
    state.picUrl=val
  },
  fullScreen(state,val){
    state.fullScreen=val
  },
  rotateing(state,val){
    state.rotateing=val
  },
  getLyric(state,val){
    state.lyric=val
  },
  lyricArr(state,val){
    state.lyricArr=val
  },
  playIndex(state,val){
    state.playIndex=val
  },
  changeMode(state,val){
    state.mode=val
  },
  percentage(state,val){
    state.percentage=val;
  },
  percentage2(state,val){
    state.percentage2=val;
  },
  //全屏切换下一首的时候改变mv的当前下标
  changeIndex(state,val){
  if(val==1){
    if(state.mode==1){
      state.reset=false
      state.songsObject.currentSongIndex--
      if(state.songsObject.currentSongIndex==-1){
        state.songsObject.currentSongIndex=state.songsObject.newAllList.length-1
      } 
    }else if(state.mode==2){
          state.reset=true
      }else if(state.mode==3){
      state.reset=false
        state.songsObject.currentSongIndex = Math.floor((state.songsObject.newAllList.length-1) * Math.random());
      }
   
    }
  else if(val==2){
     if(state.mode==1){
      state.reset=false
      state.songsObject.currentSongIndex++
      if(state.songsObject.currentSongIndex>=state.songsObject.newAllList.length){
        state.songsObject.currentSongIndex=0
      }
     }else if(state.mode==2){
      state.reset=true
      }else if(state.mode==3){
      state.reset=false
        state.songsObject.currentSongIndex = Math.floor((state.songsObject.newAllList.length-1) * Math.random());
      }
    }
  },
  click(state,val){
    state.click=val
  },
  //获取音乐播放时间进度
  musicTimeProcess(state,val){
    state.musicTimeProcess=val
  }
}